/*
    SUSAN® - Sole of Unix Save ANything

   Copyright (C) 2016-2019 Skyatlas co. ltd

   
*/

#ifndef BAREOS_DIRD_FD_CMDS_H_
#define BAREOS_DIRD_FD_CMDS_H_

namespace directordaemon {

bool ConnectToFileDaemon(JobControlRecord* jcr,
                         int retry_interval,
                         int max_retry_time,
                         bool verbose,
                         UaContext* ua = nullptr);
int SendJobInfoToFileDaemon(JobControlRecord* jcr);
bool SendIncludeList(JobControlRecord* jcr);
bool SendExcludeList(JobControlRecord* jcr);
bool SendLevelCommand(JobControlRecord* jcr);
bool SendBwlimitToFd(JobControlRecord* jcr, const char* Job);
bool SendSecureEraseReqToFd(JobControlRecord* jcr);
bool SendPreviousRestoreObjects(JobControlRecord* jcr);
int GetAttributesAndPutInCatalog(JobControlRecord* jcr);
void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId);
int put_file_into_catalog(JobControlRecord* jcr,
                          long file_index,
                          char* fname,
                          char* link,
                          char* attr,
                          int stream);
int SendRunscriptsCommands(JobControlRecord* jcr);
bool SendPluginOptions(JobControlRecord* jcr);
bool SendRestoreObjects(JobControlRecord* jcr, JobId_t JobId, bool send_global);
bool CancelFileDaemonJob(UaContext* ua, JobControlRecord* jcr);
void DoNativeClientStatus(UaContext* ua, ClientResource* client, char* cmd);
void DoClientResolve(UaContext* ua, ClientResource* client);
void* HandleFiledConnection(ConnectionPool* connections,
                            BareosSocket* fd,
                            char* client_name,
                            int fd_protocol_version);

ConnectionPool* get_client_connections();
bool IsConnectingToClientAllowed(ClientResource* res);
bool IsConnectingToClientAllowed(JobControlRecord* jcr);
bool IsConnectFromClientAllowed(ClientResource* res);
bool IsConnectFromClientAllowed(JobControlRecord* jcr);
bool UseWaitingClient(JobControlRecord* jcr_job, int timeout);

} /* namespace directordaemon */
#endif  // BAREOS_DIRD_FD_CMDS_H_
